/**
* @file 阶段组件
* @author wangcf
* @date 2017-01-09
*/
<template>
  <div class="mui-content">
    <div class="mui-scroll-wrapper" style="top: 44px;background: #f1f1f1">
      <div class="mui-scroll">
        <div class="stage_detail_li">
          <div v-show="projectname" class="list stageHeader">
            <div class="project_name" v-text="projectname"></div>
          </div>
          <div class="list" v-for="list in data">
            <div class="chance_stage_line_head"></div>
            <div @tap="check($index)" class="stage_name" :class="{'checked':list.checked}">{{list.stageName}}<span
              class="right">{{list.finishedCount}}/{{list.taskCount}}</span>
            </div>
            <div id="OA_task_2" class="detail" v-show="list.checked">
              <li v-for="detail in list.taskResultList" class="mui-icon mui-table-view-cell"
                  @click="toStageDetail(list.stageId,detail,list)">
                <div class="icon">
                  <span v-if="$index !== 0" class="top line"></span>
                  <span class="point mui-icon"><span></span></span>
                  <span v-if="$index !== (list.taskResultList.length-1)" class="bottom line"></span>
                </div>
                <div class="mui-slider-handle mui-table">
                  <a class="mui-navigate-right mui-table-cell">
                    <p class="name mui-icon">{{detail.taskName}}</p>
                    <p class="task_create_time">{{detail.status > 0 ? detail.updatedOn.length==19?
                      detail.updatedOn.substring(0,10):detail.updatedOn: ''}}</p>
                    <span class="status"
                          :class="{'notstarted': detail.status === 0,'processing': detail.status === 1,'completed': detail.status === 2 }">{{detail.statusText}}</span>
                  </a>
                </div>
              </li>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  var nativeApi = require('nativeApi');
  export default{
    props: {
      data: {},   // 详情数据
      title: '项目阶段',
      projectname: ''
    },
    methods: {
      back: function () {
        history.go(-1);
      },
      check: function (index) {
        // checked字段需在传过来前自己添加
        var self = this;
        if (self.data[index]['checked']) {
          self.data[index].checked = false;
        } else {
          self.data[index].checked = true;
        }
      },
      toStageDetail: function (item, detail, listAll) {
        this.$dispatch('toStageDetail', item, detail, listAll);
      },
      toDate: function (val) {
        return val && val.length >= 16 ? val.substring(0, 16) : '';
      }
    },
    ready: function () {
      console.info('阶段组件');
      mui('.mui-scroll-wrapper').scroll();
    }
  }
</script>
